import {
  get,
  post,
  json,
  APIURL
} from './config'

export const apiUploadUrl = 'http://192.168.100.19/'

export const uploadUrl = APIURL() + 'file/upload?type=img'

/**
 * ============== 登录 ==============
 */
// 获取登录验证码
export const getCodeImg = data => get('validatecode/getcode', data, 'blob')
// 生成动态码
export const getDynamicCode = data => post('validatecode/sendcode', data)
// 普通登陆
export const login = data => post('user/login', data)
// 动态码登陆
export const loginByCode = data => post('user/dynamicLogin', data)
// 注销
export const loginOut = data => get('user/logout', data)

/**
 * ============== 注册 ==========
 */
export const registerByPhone = data => post('user/registerByPhone', data)

export const registerByEmail = data => post('user/registerByEmail', data)
// 发送激活邮件
export const sendActivateEmail = data => post('user/sendActiveEmail', data)
// 邮箱账号激活
export const activateEmail = data => post('user/active', data)

export const getDynamicRegisterCode = data => post('validatecode/registercode', data)

/**
 * ============== 找回密码 ==========
 */
// 找回密码-验证身份
export const verifyUser = data => post('validatecode/verifyUser', data)
// 发送手机验证码
export const redeemByPhone = data => post('validatecode/redeemByPhone', data)
// 发送邮箱验证码
export const redeemByEmail = data => post('validatecode/redeemByEmail', data)
// 发送新邮箱验证码
export const redeemByNewEmail = data => post('validatecode/sendNewEmailVaildateCode', data)
// 修改密码
export const modifyPassword = data => post('user/updatePassword', data)
// 验证找回验证码
export const verifyCode = data => post('validatecode/verifyCode', data)

/**
 * 用户管理
 */
export const getUserInfo = data => get('userinfo/get', data)

export const modifyUserInfo = data => post('userinfo/update', data)

export const modifyUserPhone = data => post('userinfo/updatePhone', data)

export const getUserHistory = data => post('loginHistory/get', data)

export const modifyUserEmail = data => post('validatecode/modifyNewEmail', data)

/**
 *  我的收藏
 */
export const getArticleList = data => post('article/getCollectionList', data)

export const cancelArticle = data => post('article/CollectArticle', data)

/**
 *  我的消息
 */
export const getSystemMessage = data => post('systemMessageReceive/getList', data)

export const getSiteMessage = data => post('message/getList', data)

export const getMessageInfo = data => post('systemMessageReceive/getMessageInfo', data)

export const readNotice = data => post('systemMessageReceive/updateMsgReadStatus', data)

export const removeNotice = data => post('systemMessageReceive/deleteSysMsg', data)

export const readSiteNotice = data => post('message/batchModifyMessageStatus', data)

export const removeSiteNotice = data => post('message/batchDeleteMessage', data)

export const removeSiteSingleMessage = data => post('message/deleteMessage', data)

export const getSiteDetail = data => post('message/getMessageChat', data)

export const sendMessage = data => post('message/sendMessage', data)

export const sendMessageByAccount = data => post('message/sendMessageByAccount', data)

/**
 *  首页
 */
export const getUserFoot = data => get('footprint/get', data)

export const modifyUserFoot = data => post('footprint/save', data)

export const getUserArticle = data => post('homePage/selectArticleForUserCenter', data)

/**
 *  开放中心
 */
export const getSiteList = () => get('site/list')

export const modifySiteStar = data => post('site/collect', data)

export const removeSiteStar = data => post('site/cancelCollect', data)

/**
 *  消息设置
 */
export const getMessageSetting = data => get('messageSetting/getMessageSetting', data)

export const modifyMessageSetting = data => get('messageSetting/userMessageSetting', data)

export const addUserBlack = data => get('userBlacklist/addBlacklist', data)

export const removeUserBlack = data => get('userBlacklist/removeBlacklist', data)

export const getUserBlack = data => get('userBlacklist/getList', data)

// 专家认证

export const getAuthExpert = data => post('/expert/get', data)
export const addAuthExpert = data => json('/expert/save', data)
export const modifyAuthExpert = data => json('/expert/update', data)

// 机构认证
export const getAuthOrgs = data => post('/orgs/get', data)
export const addAuthOrgs = data => json('/orgs/save', data)
export const modifyAuthOrgs = data => json('/orgs/update', data)

// 用户认证

export const getAuthcert = data => post('/cert/get', data)
export const addAuthcert = data => json('/cert/save', data)
export const modifyAuthcert = data => json('/cert/update', data)
